//
//  DoubleViewController.m
//  UIpickview
//
//  Created by student on 16/2/23.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "DoubleViewController.h"

@interface DoubleViewController ()<UIPickerViewDataSource,UIPickerViewDelegate>

@property(nullable,strong) NSArray *left;
@property(nullable,strong) NSArray *right;
@end

@implementation DoubleViewController
- (IBAction)press:(id)sender
{
    int sel1=[self.pickview selectedRowInComponent:0];
    int sel2=[self.pickview selectedRowInComponent:1];
    self.label.text=[NSString stringWithFormat:@"何佳烨在%@%@",self.left[sel1],self.right[sel2]];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.pickview.dataSource = self;
    self.pickview.delegate = self;
    self.left=@[@"床",@"电视",@"冰箱",@"电饭锅",@"马桶"];
    self.right=@[@"上面",@"下面",@"里面"];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return  2;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    if(component==0)
    {
        return  self.left.count;
    }
    else
    {
        return self.right.count;
    }
}
-(nullable NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    if(component==0)
    {
        return self.left[row];
        
    }
    else
    {
        return  self.right[row];
    }
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
